<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="header.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add Fitting</title>
</head>

<script>
	function getObj(obj){
		return document.getElementById(obj);
	};
	$(document).ready(function(){
	    $("table tbody tr:even").addClass("tdbgcolor1"); 
	    $("table tbody tr:odd").addClass("tdbgcolor2"); 
	});
	function checkAndSubmit(){
		var form = document.getElementById("addFittingForm");
		frames['editor'].GetCon();
		if ( form.basetypeId.value==-1) {
			alert("选择基本类型");
			form.basetypeId.focus();
			return false;
		} else if (form.fittingTypeId.value==""){
			alert("请选择配件类型,如果没有配件类型，请在配件类型管理设置");
			form.fittingTypeId.focus();
			return false;
		}
		
		form.submit();
	}
	function getPeijLeixing() {
        $.ajax({
        	type: "POST",
         	url: "fetchFittingTypeByBaseId.action",
         	data: "fittingtypebaseIdQ="+$.trim($("#basetypeId")[0].value),
         	success: function(msg){
	        	var data = eval(msg);
	           	var selectObj =  document.getElementById("fittingTypeId");
	
	            var length = selectObj.length;
	       		for(var i=length-1;i>=0;i--){
	          		selectObj.remove(i);
	          	}            
	            for(var i = 0; i < data.length;i++) {
	                   selectObj.options.add(new Option(data[i].name,data[i].id));
	            }
         	}   
      	});
	}
	function showUploadWindow(id){
		var InfoW=620;
		var InfoH=400;
		var InfoUrl="edit/insert_images.action?uploadFolder=<%=com.windfone.common.Constant.UPLOAD_FITTING %>";
		var str=window.showModalDialog(InfoUrl,"","dialogWidth="+InfoW+"px;dialogHeight="+InfoH+"px;center=yes;help=no;resizable=no;status=no;scroll=no");
		if ( str != undefined){
			$("#"+id).val(str);
			$("#"+id+"1").attr("src","<%=contextPath%>/"+str);
		}		
	}		
</script>
<body>
<div align="center">新增手机配件</div>
<form method="post" action="addFitting.action" id="addFittingForm">
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"  align="center">
	<tr>
		<td width="110">配件基本类型:</td>
		<td>
		<s:select list="fittingtypebases"  listValue="name" listKey="id"  name="basetypeId"  id="basetypeId"  onchange="getPeijLeixing()"  headerKey="-1" headerValue="--请选择子类型--" ></s:select>
		 <font color="red">*</font>
		</td>
	</tr>
	<tr>
		<td >配件类型:</td>
		<td >
			 <select id="fittingTypeId" name="fittingTypeId"></select> <font color="red">*</font>
		</td>
	</tr>
	<tr>
		<td>类型:</td>
		<td><input  size="50"   type="text" name="typeName" id="typeName" />(*)</td>
	</tr>
	<tr>
		<td>主要参数:</td>
		<td><input type="text"  size="50"   name="parameter" id="parameter" /></td>
	</tr>
	<tr>
		<td>相关服务:</td>
		<td><input type="text" name="service"  size="50"   id="service" /></td>
	</tr>
	<tr>
		<td>备注:</td>
		<td><input type="text" name="memo" id="memo"  size="50"   /></td>
	</tr>
	<tr>
		<td>标准配置:</td>
		<td><input type="text" name="memo" id="memo"  size="50"   /></td>
	</tr>
	<tr>
		<td>上市时间:</td>
		<td><input type="text" name="standar" id="standar"  size="50"   /></td>
	</tr>
	<tr>
		<td>价格:</td>
		<td><input type="text" name="priceStr" id="priceStr"  value="0.0"/>(*)</td>
	</tr>
	<tr>
		<td>内容:</td>
		<td>
			<textarea id='content' name='content' style='display:none'></textarea>
		<iframe name='editor' src='edit/edit.action?V=content&T=2&A=1&uploadFolder=<%=com.windfone.common.Constant.UPLOAD_FITTING %>' frameBorder='0' marginHeight='0' marginWidth='0' scrolling='no' style='height:250px;width:640px'></iframe>
			</td>
	</tr>
	<tr> 
		<td>小图:</td>
	  	<td>
			<img name="imagepath1" id="imagepath1" src=""/><input type="button" value="照片"  onClick="showUploadWindow('imagepath')"/>(70*90)
		</td>
	</tr>
	<tr>
		<td >配件大图:</td>
	  	<td  nowrap="nowrap">
				<img src=""  id="bigimagepath1" name="bigimagepath1" border="0"/> &nbsp; <input type="button" value="照片"  onClick="showUploadWindow('bigimagepath')"/>
		</td>
	</tr>	
	<tr>
		<td colspan="2">
		<input type="hidden" name="imagepath" id="imagepath"/>
		<input type="hidden" name="bigimagepath" id="bigimagepath" />
		<input type="button" value="Save"	onclick="checkAndSubmit()" />&nbsp; 
		<input type="button" value="reset" />&nbsp; 
		<input type="button" value="返回"	onclick="javascript:window.history.back();" />
		</td>
</table>
</form>
</body>
</html>
